<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
	<base href="<%=basePath%>"><!-- jsp文件头和头部 -->
	<%@ include file="../../system/admin/top.jsp"%> 
	</head>
<body>
			<!-- 检索  -->
			<form action="project/list.do" method="post" name="Form" id="Form">
			<div class="con-form">
				<input type="text" placeholder="输入查询内容"  autocomplete="off" id="nav-search-input" name="USERNAME" value="${pd.USERNAME }"  class="input-search">
				开始日期 <input type="text" name="lastLoginStart" id="lastLoginStart" class="form_datetime date" value="${pd.lastLoginStart}"  readonly="readonly">
				结束日期 <input type="text" name="lastLoginEnd" id="lastLoginEnd" class="form_datetime date" value="${pd.lastLoginEnd}" readonly="readonly">
		        <button class="search" onclick="search();"  title="onclick="search();"  title="查询">查询</button>
		    </div>
	       	<p class="operate">
	            <a class="create Operate" title="新增" onclick="add();">新增</a>
	            <a class="delete" onclick="makeAll();" title="批量删除">批量删除</a>
	    </p>
			<!-- 检索  -->
			<table>
				<colgroup>
		            <col width="1%">
		            <col width="1%">
		            <col width="3%">
		            <col width="20%">
		            <col width="2%">
		            <col width="3%">
		            <col width="3%">
		        </colgroup>
				<thead>
					<tr>
						<th>
						<input type="checkbox" id="zcheckbox" />
						</th>
						<th>序号</th>
						<th>项目名称</th>
						<th>项目描述</th>
						<th>创建人</th>
						<th>创建时间</th>
						<th>操作</th>
					</tr>
				</thead>
										
				<tbody>
					
				<!-- 开始循环 -->	
				<c:choose>
					<c:when test="${not empty varList}">
						<c:if test="${QX.cha == 1 }">
						<c:forEach items="${varList}" var="var" varStatus="vs">
							<tr>
								<td>
								<input type='checkbox' name='ids' value="${var.project_id}" />
								</td>
						        <td>${vs.index+1}</td>
								<td>${var.project_name}</td>
								<td align="left" style="padding:0 5px 0 5px;">${var.project_remark}</td>
								<td>管理员</td>
								<td><fmt:formatDate value="${var.create_date}" pattern="yyyy-MM-dd"/></td>
								<td>
								<p class="operate">
									<c:if test="${QX.edit != 1 && QX.del != 1 }">
										<div class="operate-more">
			                                 <span class='operate-false'></span>
		                    	         </div>
									</c:if>
									<c:if test="${QX.edit == 1 }">
									<a  title="编辑" onclick="edit('${var.project_id}');" class="operatea revise" >编辑</a>
									</c:if>
									<c:if test="${QX.del == 1 }">
									<a title="删除" onclick="del('${var.project_id}');" class="operatea delete">删除</a>
									</c:if>
									</p>
								</td>
							</tr>
						</c:forEach>
						</c:if>
						<c:if test="${QX.cha == 0 }">
							<tr>
								<td colspan="100" class="center">您无权查看</td>
							</tr>
						</c:if>
					</c:when>
					<c:otherwise>
						<tr class="main_info">
							<td colspan="100" class="center" >没有相关数据</td>
						</tr>
					</c:otherwise>
				</c:choose>
				</tbody>
			</table>
			<!--分页器-->
              <div class="branchPage">${page.pageStr}</div>
			</form>
		<script type="text/javascript">
		$(function(){
			//日期插件
			  $(".form_datetime").datetimepicker( {
			      autoclose:true,
			      format: "yyyy-mm-dd",
			      language: 'cn',
			      clearBtn:true,
			      todayHighlight: true
			  });
			});
		//检索
		function search(){
			$("#Form").submit();
		}
		//修改
		function edit(Id){
			$("#zhongxin",domObj).show();
			$("#zhongxin iframe",domObj).attr("src","<%=basePath%>project/goEdit.do?project_id="+Id);
		}
		//新增
		function add(){
			$("#zhongxin",domObj).show();
			$("#zhongxin iframe",domObj).attr("src","<%=basePath%>project/goAdd.do");
		}
		
			//删除
			function del(Id){
				$.confirm('你确定要删除这条消息吗? ',null,function(type){
			        if(type==='yes'){
						var url = "<%=basePath%>project/delete.do?project_id="+Id+"&tm="+new Date().getTime();
						$.get(url,function(data){
								if(data == "success"){
									location.href="<%=basePath%>company/list.do";
								}
						});
			        }else{
			        	//do Nothing
			        }
			        this.hide();
				 });
			}

				//批量操作
				function makeAll(){
				var str = '';
				for(var i=0;i < document.getElementsByName('ids').length;i++){
					  if(document.getElementsByName('ids')[i].checked){
					  	if(str==''){
					  		str += document.getElementsByName('ids')[i].value;
					  	}else{
					  		str += ',' + document.getElementsByName('ids')[i].value;
					  	}
					  }
				}
				if(str==''){
					$("#zcheckbox").tips({
						side:1,
			            msg:'点这里全选',
			            bg:'#AE81FF',
			            time:8
			        });
					return;
				}
				$.confirm('你确定要删除这条消息吗? ',null,function(type){
			        if(type==='yes'){
			        	$.ajax({
			    			type: "POST",
			    			url: '<%=basePath%>project/deleteAll.do?tm='+new Date().getTime(),
			    	    	data: {DATA_IDS:str},
			    			dataType:'json',
			    			cache: false,
			    			success: function(data){
			    				//刷新列表页面
			    				location.href='<%=basePath%>project/list.do';
			    			}
			    		});
			        }else{
			           //do Nothing
			        }
			        this.hide();
			    });
			}
		</script>
	</body>
</html>

